package frame.laxcen.request;

import frame.laxcen.util.FrameWriter;

// 配置读写器空闲模式
public class Request_0010_0D implements IRequest {

    public final byte[] FrameBytes;

    public Request_0010_0D(RequestTemplate template) {

        FrameWriter w = FrameWriter.instance(this.getClass());

        w.writeU8(template.Enable);

        if(template.hasParam_0x01()) {

            w.writeP16((byte) 0x01, template.Pid_0x01_0);
        }

        this.FrameBytes = w.toByteArray();
    }

    @Override
    public byte[] getFrameBytes() {

        return FrameBytes;
    }

    public static class RequestTemplate {

        // 自动空闲模式使能 默认不开启
        public byte Enable = 0;

        // 自动空闲时间 默认为0
        public Short Pid_0x01_0 = 0;

        public boolean hasParam_0x01() {

            return Pid_0x01_0 != null;
        }
    }
}
